package com.ophiux.appoint.controller;

import com.ophiux.appoint.service.PayService;
import com.ophiux.appoint.service.impl.WechatPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @desc:
 * @author: hhl
 * @date：2023/9/28 15:26
 */
@RestController
@RequestMapping("/pay")
@Api(tags = "支付")
public class PayController {
    @Autowired
    private Map<String, PayService> payService;


    public volatile String dd  = "1";

    @ApiOperation("支付")
    @GetMapping
    public String pay(String pay) {
        return payService.get(pay).pay();
    }

    public static void main(String[] args) throws Exception {
        Class<?> payService1 = Class.forName("com.ophiux.appoint.service.impl.WechatPayService");
        WechatPayService wechatPayService = WechatPayService.class.newInstance();
        System.out.println(wechatPayService.pay());

        PayService o = (PayService) payService1.newInstance();
        System.out.println(o.pay());

        System.out.println(1);

    }
}
